(function(window, undefined) {
	var staticObj = cc.Sprite.extend({
		ctor	: function(opts) {
		//this._super();
			//初始化状态列表
			this.statusArr = ['create', 'normal', 'hited', 'dead'];
			this.initWithTexture(cc.TextureCache.getInstance().addImage(opts.filename), opts.rect);
			this.setContentSize(opts.size);

			// var shipTexture = cc.TextureCache.getInstance().addImage("res/images/chris.png");
   //          // set frame
   //          var frame0 = cc.SpriteFrame.createWithTexture(shipTexture, cc.rect(0, 0, 48, 64));
   //          var frame1 = cc.SpriteFrame.createWithTexture(shipTexture, cc.rect(48, 0, 48, 64));

   //          var animFrames = [];
   //          animFrames.push(frame0);
   //          animFrames.push(frame1);

   //          // ship animate
   //          var animation = cc.Animation.create(animFrames, 0.1);
   //          var animate = cc.Animate.create(animation);
   //          var rpt = cc.RepeatForever.create(animate);
   //          console.log('rpt', rpt);
   //          this.runAction(rpt);


// var ac = cc.AnimationCache.getInstance();
// 		var infoDic = dino.infoDic;


// 		var type="tree";
// 		var skin="create";
// 		var key = [type, skin].join('.');
// 		var rst;
// 		while(!(rst = ac.getAnimation(key))) {
// 			// 图片地址
// 			var ak = infoDic[type]['animDic'];
// 			var imgUrl = ak[skin].textureUrl ||  infoDic[type].textureUrl; // 如果没有专门的skin贴图,则使用默认的贴图
// 			var steps = ak.steps;
// 			var size = ak.size||infoDic[type].size;
// 			if(!imgUrl) {
// 				break;
// 			}
// 			// 贴图
// 			var tc = cc.TextureCache.getInstance();
// 			var texture = tc.addImage(imgUrl);
// 			// 帧
// 			var fc = cc.SpriteFrameCache.getInstance();
// 			var spriteFrames = [];
// 			// for(var i = 0; i < steps; i++) {
// 			// 	var si = steps[i];
// 			// 	var frame = cc.SpriteFrame.createWithTexture(texture, new cc.Rect(size.width * si[1], size.height * si[0], size.width, size.height));
// 			// 	spriteFrames.push(frame);
// 			// }
// 			            var frame0 = cc.SpriteFrame.createWithTexture(texture, cc.rect(0, 0, 48, 64));
//             var frame1 = cc.SpriteFrame.createWithTexture(texture, cc.rect(48, 0, 48, 64));

//             var animFrames = [];
//             animFrames.push(frame0);
//             animFrames.push(frame1);

//             spriteFrames=animFrames;

// 			// 帧间隔
// 			var delay = dino.config.animationDelay;
// 			// 动画
// 			var anim = cc.Animation.create(spriteFrames, delay);
// 			// 加入动画缓存
// 			ac.addAnimation(anim, key);
// 		}



// 				var animation = rst;
//    					// var animation = dino.getSkin('tree', 'create');
// 						var action = cc.Animate.create(animation);
// 						var rpt = cc.RepeatForever.create(action);
// 						this.runAction(rpt);	

		},
		onEnter: function() {
			this._super();
		 this.changeStatus('create');
		},
		// // attr
		// type: null,
		// 皮肤枚举(动画)
		skinArr: null,
		// 当前皮肤
		skin: null,
		// 属性
		prop: null,
		// 可否碰撞
		hitable: null,
		// 状态枚举
		statusArr: null,
		// 当前状态
		status: null,
		// method
		changeStatus: function(statName) {
			var index = this.statusArr.indexOf(statName);
			if(index >= 0) {
				var lastStatus = this.status;
				this.status = this.statusArr[index];
				this.trigger('afterStatusChange', {
					ostat: lastStatus,
					nstat: this.status
				});
			} else {
				throw "no such status " + statName;
			}
		},
		changeSkin: function(skinName) {
			var index = skinArr.indexOf(skinName);
			if(index >= 0) {
				this.skin = skinArr[index];
			} else {
				throw "no such skin " + skinName;
			}
		},
		// events
		/*
		events: {
			beforeCreate: null,
			creating: null,
			afterCreate: null,
			timer: null,
			beforeDead: null,
			dying: null,
			afterDead: null,
			afterStatusChange: null
		},
		*/
		// 绑定事件
		attach: function(eventName, fn) {
			var dic = this.__eventList__ = this.__eventList__ || {};
			var edic = dic[eventName] = dic[eventName] || {};
			var eid = new Date().getTime();
			edic[eid] = fn;
			return eid;
		},
		// 反绑定事件
		// 如果eid为空,则全部都反绑定
		detach: function(eventName, eid) {
			var dic = this.__eventList__ = this.__eventList__ || {};
			var edic = dic[eventName] = dic[eventName] || {};
			if(eid !== undefined) {
				if(edic[i]) {
					delete edic[i];
				}
			} else {
				for(var i in edic) {
					delete edic[i];
				}
			}
		},
		// 触发
		trigger: function(eventName, opts) {
			var dic = this.__eventList__ = this.__eventList__ || {};
			var edic = dic[eventName] = dic[eventName] || {};
			for(var i in edic) {
				edic[i](opts);
			}
		}
	});
	window.staticObj = staticObj;
})(window);



// var Ship = cc.Sprite.extend({
//     speed:220,
//     bulletSpeed:900,
//     HP:5,
//     bulletTypeValue:1,
//     bulletPowerValue:1,
//     throwBombing:false,
//     canBeAttack:true,
//     isThrowingBomb:false,
//     zOrder:3000,
//     maxBulletPowerValue:4,
//     appearPosition:cc.p(160, 60),
//     _hurtColorLife:0,
//     active:true,
//     ctor:function () {
//         // needed for JS-Bindings compatibility
//         cc.associateWithNative( this, cc.Sprite );
//         //init life
//         var shipTexture = cc.TextureCache.getInstance().addImage("res/images/chris.png");
//         this.initWithTexture(shipTexture, cc.rect(0, 0, 60, 38));
//         this.setTag(this.zOrder);
//         this.setPosition(this.appearPosition);
//         // set frame
//         var frame0 = cc.SpriteFrame.createWithTexture(shipTexture, cc.rect(0, 0, 60, 38));
//         var frame1 = cc.SpriteFrame.createWithTexture(shipTexture, cc.rect(60, 0, 60, 38));
//         var animFrames = [];
//         animFrames.push(frame0);
//         animFrames.push(frame1);
//         // ship animate
//         var animation = cc.Animation.create(animFrames, 0.1);
//         var animate = cc.Animate.create(animation);
//         this.runAction(cc.RepeatForever.create(animate));
//        }
// });